<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('报价实体列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>竞价信息表ID：</label>
                                <input type="text" name="bidInfoId"/>
                            </li>
                            <li>
                                <label>供应商ID：</label>
                                <input type="text" name="supplierId"/>
                            </li>
                            <li>
                                <label>报价金额：</label>
                                <input type="text" name="offerAmount"/>
                            </li>
                            <li class="select-time">
                                <label>报价参数：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginCrateTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endCrateTime]"/>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:offerinfo:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:offerinfo:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:offerinfo:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:offerinfo:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:offerinfo:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:offerinfo:remove')}]];
        var prefix = ctx + "system/offerinfo";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "报价实体",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'offerInfoId',
                    title: '报价ID',
                    visible: false
                },
                {
                    field: 'bidInfoId',
                    title: '竞价信息表ID',
                    visible: false
                },
                {
                    field: 'unitName',
                    title: '采购单位'
                },
                {
                    field: 'goodName',
                    title: '报价产品型号'
                },
                {
                    field: 'goodsName',
                    title: '采购需求名称'
                },
                {
                    field: 'beginTime',
                    title: '开始时间'
                },
                {
                    field: 'endTime',
                    title: '结束时间'
                },
                {
                    field: 'offerAmount',
                    title: '报价金额'
                },
                {
                    field: 'demand',
                    title: '采购详细需求'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.offerAmount == null||row.offerAmount==""||row.offerAmount==undefined||row.offerAmount=="null"){
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="baojia(\'' + row.bidInfoId + '\',\'' + row.count + '\',\'' + row.demand + '\',\'' + row.purchaseItemId + '\',\'' + row.offerAmount + '\',\'' + row.endTime + '\')"><i class="fa fa-edit"></i>报价</a> ');
                        }
                        /*actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.offerInfoId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.offerInfoId + '\')"><i class="fa fa-remove"></i>删除</a>');*/
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function baojia(id,count,demand,purchaseItemId,money,endTime) {

            console.log(id)
            var dB = new Date(endTime.replace(/-/g, "/"));
            if (new Date() > Date.parse(dB)) {
                $.modal.alertError("截止时间已过，无法报价！");
            }else{
                if(money==null||money==""||money==undefined||money=="null"){
                    var url = '/system/offerinfo/addModel?bidInfoId='+id+'&purchaseItemId='+purchaseItemId +'&count='+count+'&demand='+demand;
                    $.modal.open("报价", url);
                }else{
                    $.modal.alertWarning("您已经参与了报价！");
                }
            }

        }
    </script>
</body>
</html>